package com.whnk.web.controller.pm;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.whnk.common.annotation.Log;
import com.whnk.common.enums.BusinessType;
import com.whnk.pm.domain.CtrInfo;
import com.whnk.pm.domain.CtrNmList;
import com.whnk.pm.service.ICtrInfoService;
import com.whnk.pm.service.ICtrNmListService;
import com.whnk.framework.web.base.BaseController;
import com.whnk.framework.web.page.TableDataInfo;
import com.whnk.common.base.AjaxResult;

/**
 * 订单人员名单 信息操作处理
 * 
 * @author whwhnk
 * @date 2019-07-15
 */
@Controller
@RequestMapping("/pm/ctrNmList")
public class CtrNmListController extends BaseController
{
    private String prefix = "pm/ctrNmList";
	
	@Autowired
	private ICtrNmListService ctrNmListService;
	
	@Autowired
	private ICtrInfoService ctrInfoService;
	
	@RequiresPermissions("pm:ctrNmList:view")
	@GetMapping()
	public String ctrNmList()
	{
	    return prefix + "/ctrNmList";
	}
	
	/**
	 * 查询订单人员名单列表
	 */
	@RequiresPermissions("pm:ctrNmList:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(CtrNmList ctrNmList)
	{
		startPage();
        List<CtrNmList> list = ctrNmListService.selectCtrNmListList(ctrNmList);
		return getDataTable(list);
	}
	
	/**
	 * 新增订单人员名单
	 */
	@GetMapping("/add/{ctrId}")
	public String add(@PathVariable("ctrId") Integer ctrId, ModelMap mmap)
	{
		CtrInfo ctrInfo = ctrInfoService.selectCtrInfoById(ctrId);
		mmap.put("ctrInfo", ctrInfo);
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存订单人员名单
	 */
	@RequiresPermissions("pm:ctrNmList:add")
	@Log(title = "订单人员名单", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(CtrNmList ctrNmList)
	{		
		return toAjax(ctrNmListService.insertCtrNmList(ctrNmList));
	}

	/**
	 * 修改订单人员名单
	 */
	@GetMapping("/edit/{nlId}")
	public String edit(@PathVariable("nlId") Integer nlId, ModelMap mmap)
	{
		CtrNmList ctrNmList = ctrNmListService.selectCtrNmListById(nlId);
		mmap.put("ctrNmList", ctrNmList);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存订单人员名单
	 */
	@RequiresPermissions("pm:ctrNmList:edit")
	@Log(title = "订单人员名单", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(CtrNmList ctrNmList)
	{		
		return toAjax(ctrNmListService.updateCtrNmList(ctrNmList));
	}
	
	/**
	 * 删除订单人员名单
	 */
	@RequiresPermissions("pm:ctrNmList:remove")
	@Log(title = "订单人员名单", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(ctrNmListService.deleteCtrNmListByIds(ids));
	}
	
}
